<template>
	<view class="rh-radio-container">
		<view class="radio-item">
			<view class="radio-label">
				<slot name="label-icon"></slot>
				<text class="label-txt">{{label}}</text>
			</view>
			<view class="radio-content">
				<radio-group class="radio-group" @change="radioChange">
					<label class="group-item" v-for="(item, index) in radioList" color="#22984E" :key="item.dictCode">
						<radio style="transform:scale(0.6)" :value="item.dictCode" :checked="item.dictCode === emitValue"/>
						<view class="label-txt">{{item.dictLabel}}</view>
					</label>
				</radio-group>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			label: String,
			value: [Boolean, String, Number],
			disabled: {
				type: Boolean,
				default: () => {return false}
			},
			radioList: {
				type: Array,
				default: () => {return [
					{dictLabel: '正常', dictCode: '0', disabled: false},
					{dictLabel: '异常', dictCode: '1', disabled: false}
				]}
			},
		},
		watch: {
			value(val){
				this.emitValue = val
			},
		},
		data() {
			return {
				emitValue: this.value
			};
		},
		mounted() {
			this.emitValue = this.value
		},
		methods: {
			radioChange(e){
				let _self = this
				_self.$emit('input', e['detail'].value)
				_self.$emit('change',e['detail'].value)
			},
		}
	}
</script>

<style scoped lang="scss">
	.rh-radio-container{
		width: 100%;
	}
	.radio-item{
		display: flex;
		justify-content: space-between;
		align-items: center;
		.radio-label{
			display: flex;
			align-items: center;
			.label-txt{
				font-size: 26rpx;
				color: #666;
			}
		}
		.radio-content{
			display: flex;
			align-items: center;
		}
		.radio-group{
			display: flex;
			align-items: center;
			.group-item{
				display: flex;
				align-items: center;
				margin-left: 16rpx;
			}
			.label-txt{
				font-size: 26rpx;
			}
		}
	}
</style>
